package com.lzxuni.modules.plantingprogram.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lzxuni.common.utils.StringUtils;
import com.lzxuni.modules.common.entity.PageParameter;
import com.lzxuni.modules.common.entity.Tree;
import com.lzxuni.modules.plantingprogram.entity.PlantingProgramUse;
import com.lzxuni.modules.plantingprogram.mapper.PlantingProgramUseMapper;
import com.lzxuni.modules.plantingprogram.service.PlantingProgramUseService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 种植方案_使用 服务实现类
 * </p>
 *
 * @author rdf
 * @since 2020-12-18
 */
@Service
public class PlantingProgramUseServiceImpl extends ServiceImpl<PlantingProgramUseMapper, PlantingProgramUse> implements PlantingProgramUseService {

    @Override
    public PageInfo<PlantingProgramUse> queryPage(PageParameter pageParameter, PlantingProgramUse plantingProgramUse) {
        if (StringUtils.isNotEmpty(pageParameter.getSidx())) {
            PageHelper.startPage(pageParameter.getPage(), pageParameter.getRows()).setOrderBy(
                    pageParameter.getSidx() + " " + pageParameter.getSord());
        } else {
            PageHelper.startPage(pageParameter.getPage(), pageParameter.getRows());
        }
        List<PlantingProgramUse> plantingProgramUseList = baseMapper.queryList(plantingProgramUse);
        PageInfo<PlantingProgramUse> pageInfo = new PageInfo<>(plantingProgramUseList);
        return pageInfo;
    }

//    方案选择查询tree
    @Override
    public List<Tree> queryFangAn(String landId) {
        List<Tree> list = baseMapper.queryFangAn(landId);
        return list;
    }

    @Override
    public PlantingProgramUse queryFanKui(String keyValue) {
        return baseMapper.queryFanKui(keyValue);
    }

}
